package com.yyjj.hangqing.activity;

import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.aries.ui.view.title.TitleBarView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.vise.xsnow.http.ViseHttp;
import com.vise.xsnow.http.callback.ACallback;
import com.vise.xsnow.http.mode.CacheMode;
import com.yyjj.hangqing.R;
import com.yyjj.hangqing.adapter.ZjlxAdpter;
import com.yyjj.hangqing.entity.ZjkxEntity;

import java.util.ArrayList;

import tech.com.commoncore.app.FastManager;
import tech.com.commoncore.base.BaseRefreshLoadActivity;
import tech.com.commoncore.constant.ApiConstant;
import tech.com.commoncore.entity.BaseTResp;

/**
 * 资金流向
 */
@Route(path = "/hq/zjlx")
public class ZjlxActivity extends BaseRefreshLoadActivity<ZjkxEntity> {


    @Override
    public BaseQuickAdapter<ZjkxEntity, BaseViewHolder> getAdapter() {
        return new ZjlxAdpter();
    }

    @Override
    public void loadData(int page) {
        ViseHttp.GET("yapi/cngold/currencyList")
                .baseUrl(ApiConstant.BASE_URL)
                .addParam("page", ""+page+1)
                .addParam("pagesize", "10")
                .addParam("symbol", "ELA")
                .setHttpCache(true)
                .cacheMode(CacheMode.FIRST_REMOTE)
                .request(new ACallback<BaseTResp<ArrayList<ZjkxEntity>>>() {
                    @Override
                    public void onSuccess(BaseTResp<ArrayList<ZjkxEntity>> data) {
                        if (data.data != null) {
                            FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), data.data, null);
                        } else {
                            FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), null, null);
                        }
                    }

                    @Override
                    public void onFail(int errCode, String errMsg) {
//                        FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), null, null);
                    }
                });
    }

    @Override
    public void setTitleBar(TitleBarView titleBar) {
            titleBar.setTitleMainText("资金流向");
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_zjlx;
    }

    @Override
    public void initView(Bundle savedInstanceState) {

    }
}
